//Stephen Kirksharian
//Robert Harkreader
//CPSC 321
//DUE 4/27/08

//ADDU, SUBU, ADDIU, SLTU, SLTIU = 0 ELSE THERE 0

`define ADDU 6'b100001
`define SUBU 6'b100011
`define SLTU 6'b101011
`define SLTIU 6'b001011
`define ADDIU 6'b001001
`define RTYPE 6'b000000

module sign_control(funct,opcode,control);

	input [5:0] funct,opcode;
	output control;
	reg control;

always @(funct or opcode) begin
	if (opcode==`RTYPE) 
	begin
		case(funct)
		`ADDU: begin
		  control=0;
		end
		`SUBU: begin
		  control=0;
		end

		`SLTU: begin
		  control=0;
		end

		default: begin
		  control=1;
		end

		endcase
	end
	else begin
	 control=1;
	end
	
	//if the control is zero we don't need to check addiu or sltiu

	if (opcode==`ADDIU && control==1) begin  	 control=0;
	end
	if (opcode==`SLTIU && control==1) begin
	 control=0;
	end
end

endmodule


